package com.berchen.schedule;

import com.berchen.common.busidb.model.MonthBillVo;
import com.berchen.common.busidb.service.BusidbService;
import com.berchen.utils.DateTimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 定时任务
 */
@Component
@EnableScheduling       // 单线程的 就算有多个@Scheduled 也是单线程
public class GlobalSchedule {

    @Autowired
    private BusidbService busidbService;
    /**
     * 每分钟执行一次该方法
     */
    @Scheduled(cron = "0 0/1 * * * ? ")
    public void schedule1(){
        // 实时更新余额
        busidbService.updateBalance();
    }
//    // 每个月1号 凌晨2点执行
//    @Scheduled(cron = "0 0 2 1 * ? ")
////    @Scheduled(cron = "0/9 * * * * ? ")
//    public void schedule(){
//        // 生成上个月的月账单
//        MonthBillVo monthBillVo = new MonthBillVo();
//        LocalDate localDate = LocalDate.now().minusMonths(1);
//        monthBillVo.setSDate(DateTimeUtils.getFirstDayOfMonth(localDate));
//        monthBillVo.setEDate(DateTimeUtils.getLastDayOfMonth(localDate));
//        busidbService.createMonthBIll(monthBillVo);
//
//    }

    public static void main(String[] args){

        Set<Integer> set=new HashSet<>();

        List<Integer> list=new ArrayList<>(null);
        System.out.println(list);

    }
}
